<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var lengthOfLastWord = function (s) {
        let arr = s.split(" ");
        const filArr = arr.filter((item) => {
          return item != "";
        });
        console.log(arr, filArr);
        return filArr[filArr.length - 1].length;
      };
      lengthOfLastWord("   fly me   to   the moon  ");
    </script>
  </body>
</html>
